<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Log;
use Splunk;
use Illuminate\Routing\Route;

class LogRequests
{
    public function handle(Request $request, \Closure $next)
    {
        $startTime = microtime(true);
        $response = $next($request);
        $finishTime = microtime(true);
        $url = $request->fullUrl();
        $method = $request->method();
        $statusCode = $response->getStatusCode();
        $time = (int)(($finishTime - $startTime) * 1000);
        Log:info('参数', $request->all());
        Log::info("{$method} {$url} - {$statusCode} - {$time}");

        return $response;
    }
}
